<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/5/11
 * Time: 10:28
 */

namespace Modules\Api\Http\Controllers;


use Illuminate\Support\Facades\Request;
use HiCommon\Service\JpushService;

class JpushController extends BaseController
{

    public function pushNotify( Request $request ){
        $arr_input = (array) $request::all();
        return JpushService::pushNotify( (array) $arr_input );
    }



    public function pushNotify_one(  Request $request ){
        $arr_input = (array) $request::all();
        return JpushService::pushNotifyToone( (array) $arr_input );
    }

    //ces
        public function text(){
            //获取所有的活动列表
            $where = ['pay_status' => 2 , 'status'=>0 ];
             $field = ['id', 'created_at','user_id'];
            $arr_list = \HiCommon\Repository\RoadRescueOrderRepository::get_all((array)$where ,(array) $field);
            dd($arr_list );
            if (!empty($arr_list)) {
                $str = '';
                $num = 0;
                foreach ($arr_list as $key => $vo) {
                    if (time() - $vo['created_at'] > 15 * 60) {
                        $str .= $vo['id'] . ',';
                        $num++;
                        $temp2['status'] = 4;
                        $temp2['id'] = $vo['id'];
                        \HiCommon\Repository\RoadRescueOrderRepository::edit_one($temp2);

                        $arr_jpush['title'] = '系统消息';
                        $arr_jpush['content'] = '订单超时未支付自动取消';
                        $arr_jpush['user_id'] = $vo['user_id'];
                        $arr_jpush['extras']['pid'] = 1;
                        \HiCommon\Service\JpushService::pushNotifyToone( (array) $arr_jpush );

                    }
                }
//                //添加日志
//                $log_data['time'] = date("Y-m-d H:i:s");
//                $log_data['num'] = $num;
//                $log_data['activity_ids'] = trim($str, ',');
//                $temp = 'ok, 成功修改' . $num . '条活动数据，【' . $log_data['activity_ids'] . '】';
//                LogRepository::record_change_activity((array)$log_data);
//                return hello_success($temp);
            }

        }


}


